package com.gwl.linkoptionspicker;

import static android.widget.Toast.LENGTH_SHORT;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectChangeListener;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;

import java.util.ArrayList;

public class Utils {
    /**
     * 弹出三级选择列表
     */
    public static void initNoLinkOptionsPicker3(ArrayList<String> positionItem, ArrayList<ArrayList<String>> positionItem2, ArrayList<ArrayList<ArrayList<String>>> positionItem3, Context context) {// 不联动的多级选项
        //条件选择器
        OptionsPickerView pvOptions = new OptionsPickerBuilder(context, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3 ,View v) {
                //返回的分别是三个级别的选中位置
//                String tx = options1Items.get(options1).getPickerViewText()
//                        + options2Items.get(options1).get(option2)
//                        + options3Items.get(options1).get(option2).get(options3).getPickerViewText();
//                tvOptions.setText(tx);
            }
        }).build();
        pvOptions.setPicker(positionItem, positionItem2, positionItem3);
        pvOptions.show();
    }

    /**
     * 弹出二级选择列表
     */
    public static void initNoLinkOptionsPicker2(ArrayList<String> positionItem, ArrayList<String> positionItem2, Context context) {// 不联动的多级选项
        OptionsPickerView pvNoLinkOptions = new OptionsPickerBuilder(context, new OnOptionsSelectListener() {

            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {

                String str = "noe:" + positionItem.get(options1) + "tow:" + positionItem2.get(options2);

                Toast.makeText(context, str, LENGTH_SHORT).show();
            }
        })
                .setOptionsSelectChangeListener(new OnOptionsSelectChangeListener() {
                    @Override
                    public void onOptionsSelectChanged(int options1, int options2, int options3) {
                        String str = "options1: " + options1 + "options2: " + options2;
                        Toast.makeText(context, str, LENGTH_SHORT).show();
                    }
                })
                .setItemVisibleCount(5)
                .setCancelText("取消")
                .setSubmitText("确定")
                .build();
        pvNoLinkOptions.setNPicker(positionItem, positionItem2, null);
        pvNoLinkOptions.show();
    }

    /**
     * 弹出一级选择列表代理人
     */
    public static void initNoLinkOptionsPicker1(ArrayList<String> positionItem, Context context, String cancelColor, String submitColor) {// 不联动的多级选项
        OptionsPickerView pvNoLinkOptions = new OptionsPickerBuilder(context, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                String str = "noe:" + positionItem.get(options1);

                Toast.makeText(context, str, LENGTH_SHORT).show();
            }
        })
                .setItemVisibleCount(5)
                .setCancelText("取消")
                .setCancelColor(Color.parseColor(cancelColor))
                .setSubmitColor(Color.parseColor(submitColor))
                .setSubmitText("确定")
                // .setSelectOptions(0, 1, 1)
                .build();
        pvNoLinkOptions.setNPicker(positionItem, null, null);
        pvNoLinkOptions.setSelectOptions(0);
        pvNoLinkOptions.show();
    }


}
